package lumis.portal.audit;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;

/**
 * Represents the audit configuration.
 *
 * @version $Revision: 13093 $ $Date: 2011-05-28 18:40:18 -0300 (Sat, 28 May 2011) $
 * @since 6.0.0
 */
@Entity
@GenericGenerator(name="portal-guid", strategy="lumis.portal.dao.hibernate.GuidGenerator")
@Table(name="lum_AuditConfig")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class AuditConfig
{
	@Id	@GeneratedValue(generator="portal-guid")
	@Column(name="auditConfigId", nullable=false)
	private String id;
	
	@Column(name="cleanInterval", nullable=false)
	private int cleanInterval = 30;

	/**
	 * Returns the audit configuration id.
	 * @return	the audit configuration id.
	 * @since 6.0.0
	 */
	public String getId()
	{
		return id;
	}

	/**
	 * Returns the time interval (in days) for audit entries clean up. 
	 * @return the time interval for audit entries clean up.
	 * @since 6.0.0
	 */
	public int getCleanInterval()
	{
		return cleanInterval;
	}

	/**
	 * Changes the value of time interval (in days) for audit entries clean up.
	 * @param cleanInterval 	the new time interval for audit entries clean up.
	 * @since 6.0.0
	 */
	public void setCleanInterval(int cleanInterval)
	{
		if (cleanInterval <= 0)
		{
			throw new IllegalArgumentException("'cleanInterval' cannot be minor than 1");
		}	
		
		this.cleanInterval = cleanInterval;
	}	
}